use crate::conversion::conversion_enum::ConversionEnum;
use crate::Stack;

pub fn base_conversion(mut dec_num: usize, conver: ConversionEnum) -> String {
    let mut rem_stack = Stack::new();
    let conversion = ConversionEnum::new(conver);
    while dec_num > 0 {
        let rem = dec_num % conversion.get_device();
        rem_stack.push(conversion.get_data(rem));
        dec_num = dec_num / conversion.get_device();
    }
    let mut bin_str = conversion.get_prefix();
    while !rem_stack.is_empty() {
        let rem = rem_stack.pop().unwrap().to_string();
        bin_str += &rem;
    }
    bin_str
}
